import axios from '@/plugins/axios';
const BASE_API = import.meta.env.VITE_APP_BASE_APIURL as string;

import { CommontTypes, ResponseVo, CouponTypes, PromoTypes } from '@/type';

export namespace PromoService {
  export const pagePromo = async (data:PromoTypes.PagePromoType & CommontTypes.IPaginationParam): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/promotype/page',{params:data, baseURL: BASE_API});
    return res;
  };

  export const addPromo = async (data:PromoTypes.IPromoItem): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/promotype/add',data,{baseURL: BASE_API});
    return res;
  };

  export const editPromo = async (data:PromoTypes.IPromoItem): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/promotype/edit',data,{baseURL: BASE_API});
    return res;
  };

  export const detailPromo = async (id:number): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/promotype/detail',{params:{id}, baseURL: BASE_API});
    return res;
  };

  export const listPromo = async (): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/promotype/list',{baseURL: BASE_API});
    return res;
  };
}
